package com.study.system.common.util;
//这段代码的作用是提供一个工具方法，用于从 HTTP 请求中提取并解析出身份验证 Token
import cn.hutool.core.util.StrUtil;
import com.study.system.common.constant.SecurityConstants;
import jakarta.servlet.http.HttpServletRequest;


public class RequestUtils {


    public static String resolveToken(HttpServletRequest request) {
        String bearerToken = request.getHeader(SecurityConstants.TOKEN_KEY);
        if (StrUtil.isNotBlank(bearerToken) && bearerToken.startsWith(SecurityConstants.TOKEN_PREFIX)) {
            return bearerToken.substring(SecurityConstants.TOKEN_PREFIX.length());
        }
        return null;
    }
}
